<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>修改商品</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="css/add_goods.css">
	<script type="text/javascript">
		//修改商品信息
		var color_value="";
		var size_value="";
		var photos_value="";
		
		var i=1;
		var colorvalue;
		var myText;
		function add_text1(){
			if(i==1){
				colorvalue=document.getElementById("color_Id1").value;
				if(colorvalue==""){
					alert("前面输入为空，不能添加");
				}else{
					
					var colorObj =document.getElementById("color_div");
					myText=document.createElement("input");
					myText.type="text";	
					myText.style.width="50px";
					myText.id="color_Id"+(i+1);			
					colorObj.appendChild(myText);
					i++;
				}
			}else{
				colorvalue=myText.value;
				if(colorvalue==""){
					alert("前面输入为空，不能添加");
				}else{
					
					var colorObj =document.getElementById("color_div");
					myText=document.createElement("input");
					myText.type="text";	
					myText.style.width="50px";
					myText.id="color_Id"+(i+1);	
					colorObj.appendChild(myText);					
					i++;
				}
			}
			
		} 
		
		var j=1;
		var sizevalue;
		var mySize;
		function add_text2(){
			if(j==1){
				sizevalue=document.getElementById("size_Id1").value;
				if(sizevalue==""){
					alert("前面输入为空，不能添加");
				}else{
				
					var sizeObj =document.getElementById("size_div");
					mySize=document.createElement("input");
					mySize.type="text";	
					mySize.style.width="50px";
					mySize.id="size_Id"+(j+1);			
					sizeObj.appendChild(mySize);
					j++;
				}
			}else{
				sizevalue=mySize.value;
				if(sizevalue==""){
					alert("前面输入为空，不能添加");
				}else{
					
					var sizeObj =document.getElementById("size_div");
					mySize=document.createElement("input");
					mySize.type="text";	
					mySize.style.width="50px";
					mySize.id="size_Id"+(j+1);	
					sizeObj.appendChild(mySize);					
					j++;
				}
			}
			
			
		} 
		
		/* 校验  */
		function losefocus1(){
		
			if(document.getElementById("nameId").value==""){
				document.getElementById("null_span1").innerText="名称不能为空";
			}
				
		}
	    function getfocus1(){
		
			
			document.getElementById("null_span1").innerText="";
			
				
		}	
		function losefocus2(){
		
			if(document.getElementById("brandId").value==""){
				document.getElementById("null_span2").innerText="品牌不能为空";
			}
				
		}
	    function getfocus2(){
		
			
			document.getElementById("null_span2").innerText="";
			
				
		}	
		function losefocus3(){
		
			if(document.getElementById("numId").value==""){
				document.getElementById("null_span3").innerText="数量不能为空";
			}
				
		}
	    function getfocus3(){
		
			
			document.getElementById("null_span3").innerText="";
			
				
		}	
		function losefocus4(){
		
			if(document.getElementById("priceId").value==""){
				document.getElementById("null_span4").innerText="价格不能为空";
			}
				
		}
	    function getfocus4(){
		
			
			document.getElementById("null_span4").innerText="";
			
				
		}	
		
		function losefocus6(){
		
			if(document.getElementById("detailsId").value==""){
				document.getElementById("null_span6").innerText="详情信息不能为空";
			}
				
		}
	    function getfocus6(){
					
			document.getElementById("null_span6").innerText="";
				
		}	
		
		function losefocus7(){
		
			if(document.getElementById("colorId").value==""){
				document.getElementById("null_span7").innerText="颜色不能为空";
			}
				
		}
	    function getfocus7(){
					
			document.getElementById("null_span7").innerText="";
				
		}	
		
		function losefocus8(){
		
			if(document.getElementById("sizeId").value==""){
				document.getElementById("null_span8").innerText="尺寸不能为空";
			}
				
		}
	    function getfocus8(){
					
			document.getElementById("null_span8").innerText="";
				
		}	
	
		function jiaoyan_all(){
			var bol=true;
			
	
			if(document.getElementById("nameId").value==""){
				bol=false;
				alert("名称不能为空");
			}else if(document.getElementById("colorId").value==""){
				bol=false;
				alert("颜色不能为空");
			}else if(document.getElementById("sizeId").value==""){
				bol=false;
				alert("尺寸不能为空");
			}else if(document.getElementById("brandId").value==""){
				bol=false;
				alert("品牌不能为空");
			}else if(document.getElementById("numId").value==""){
				bol=false;
				alert("数量不能为空");
			}else if(document.getElementById("priceId").value==""){
				bol=false;
				alert("价格不能为空");
			}else if(document.getElementById("detailsId").value==""){
				bol=false;
				alert("详情信息不能为空");
			}
			
			
			
			return bol;
		}
		
		function success() {
			alert("更新成功");
		
		}
	</script>

  </head>
  
  <body>
  	<!--总div  -->
     <div class="div_all">
     
     	<%-- <div class="div_1">
     			<div style="position: absolute;">
			<c:if test="${username1!=null}">
				<span style="color:red;">用户名: ${username1}</span>
			</c:if>
			<c:if test="${username1==null}">
				<a href="qiehuanUser.do" style="text-decoration: none;color:red;">亲，请登入</a>
			</c:if></div>
			<!-- <div class="div_menu">
				<a href="add_goods_showtype.do" class="a_menu">添加商品 </a>
  				<a href="show_goods.do" class="a_menu">查询商品 </a>
  				<a href="add_type.do" class="a_menu">类别管理 </a>
  				<a href="show_ads.do" class="a_menu">广告维护 </a>
  				<a href="zhuce.jsp" class="a_menu">注册账号 </a>
  				<a href="qiehuanUser.do" class="a_menu">切换账号 </a>
  				<a href="select_orders.do" class="a_menu">订单查询 </a>
  				<a href="go_tongji.do" class="a_menu">销售统计 </a>
			</div> -->
  						
     		</div>
     	</div> --%>
     	
     	<div class="div_2">
     		<!-- 添加div -->
     		<div class="div_add" style="width:800px;height:1000px;">
	     		<form action="update_good.do" method="post" enctype="multipart/form-data" onsubmit="return jiaoyan_all()" >
	     		
	     			<!-- 名称 -->
	     			<div style="margin-top:30px;">名称:<input value="${good.name}" type="text" name="name" id="nameId" onblur="losefocus1()" onfocus="getfocus1()"/><br/><span class="jiaoyan" id="null_span1"></span></div>	 
	     			<!-- 类型 -->		
	     			<div>类型:<select name="type" >
	     					<option>${good.type}</option>
	     					<c:forEach items="${typeList}" var="list">
	     						<option>${list.type}</option>
	     					</c:forEach>
	     				</select></div>
	     			<!-- 品牌 -->
	     			<div>品牌:<input value="${good.brand}" type="text" name="brand" id="brandId" onblur="losefocus2()"onfocus="getfocus2()"/><br/><span class="jiaoyan" id="null_span2"></span></div><br/>
	     			<div>供应商:<select name="gys" >
	     					<option>${good.gys}</option>
	     					<c:forEach items="${gysList}" var="list1">
	     						<option>${list1.name}</option>
	     					</c:forEach>
	     				</select></div>
	     			<div>颜色:<input value="${good.color}" type="text" name="color" id="colorId" onblur="losefocus7()"onfocus="getfocus7()"/><br/><span class="jiaoyan" id="null_span7"></span></div><br/>
	     		
	     		    <div>尺寸:<input value="${good.size}"  type="text" name="size"  id="sizeId" onblur="losefocus8()"onfocus="getfocus8()"/><br/><span class="jiaoyan" id="null_span8"></span></div><br/>

	     			 	     			
	     			<div>数量:<input value="${good.num}" type="text" name="num" id="numId" onblur="losefocus3()" onfocus="getfocus3()" /><br/><span class="jiaoyan" id="null_span3"></span></div>
	     			
	     			<div>价格:<input value="${good.price}" type="text" name="price" id="priceId" onblur="losefocus4()" onfocus="getfocus4()" /><br/><span class="jiaoyan" id="null_span4"></span></div>
	     			<div>促销价格:<input value="${good.cxprice}" type="text" name="cxprice" id="cxpriceId" /><br/></div>
	     		
	     			
	     			<div>详情信息:<textarea  rows="5" cols="50" name="details" id="detailsId" onblur="losefocus6()" onfocus="getfocus6()"  style="margin-left:20px; font-size:13">${good.details}</textarea>
	     			<br/><span class="jiaoyan" id="null_span6" style="margin-left:90px;" ></span></div>
	     			
	     			<br/><div class="mainphoto_div">主视图片:&nbsp;&nbsp;&nbsp;&nbsp;<span>${good.mainphoto}"</span><input type="file"  name="mainphotoName" /></div>
	     			<br/><div class="photos_div">浏览图片:<br/><br/>
	     						<span>${good.photo1}</span><input  type="file"  id="photos_Id1" name="photo1Name"/><br/><br/>
	     						<span>${good.photo2}</span><input  type="file"  id="photos_Id2" name="photo2Name"/><br/><br/>
	     						<span>${good.photo3}</span><input  type="file"  id="photos_Id3" name="photo3Name"/><br/><br/>
	     						<span>${good.photo4}</span><input  type="file"  id="photos_Id4" name="photo4Name"/></div><br/>
	     			
	     			<input value="${good.mainphoto}" type="hidden" name="mainphoto" id="mainphoto_id"/>
	     			<input value="${good.photo1}" type="hidden" name="photo1" id="photo1_id"/>
					<input value="${good.photo2}" type="hidden" name="photo2" id="photo2_id"/>
	     			<input value="${good.photo3}" type="hidden" name="photo3" id="photo3_id"/>
	     			<input value="${good.photo4}" type="hidden" name="photo4" id="photo4_id"/>
	     			<input value="${good.id}" type="hidden" name="id" />
	     			
	     			<input type="submit" value="确定" style="width:60px; height:30px;margin:120px 50px;" class="Mysubmit" onclick="success()"/>
	     		</form>
     		</div>
     	</div>
     	
     </div>
  </body>
</html>
